package com.zk;

import com.google.common.collect.Lists;

import java.util.List;
import java.util.Scanner;

public class Recursion {

    private static int plus(int n) {

        if (n == 0 || n == 1) {
            return 1;
        }
        return n * plus(n - 1);
    }

    private static void printStarsA(int n) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= i; j++) {
                System.out.print("* ");
            }
            System.out.println();
        }
    }

    private static void printStarsB(int n) {
        //倒三角后的正三角满足质数,每次增加2个1不算在内从3开始
        int k = 3;
        for (int i = 0, s = n; i < n; i++) {
            if (i <= n / 2) {
                for (int j = 0; j < i; j++) {
                    System.out.print("  ");
                }
                for (int j = i; j < s - i; j++) {
                    System.out.print("* ");
                }
                System.out.println();
            } else {
                for (int j = 0; j < n - i - 1; j++) {
                    System.out.print("  ");
                }
                for (int j = 0; j < k; j++) {
                    System.out.print("* ");
                }
                System.out.println();
                k = k + 2;
            }

        }
    }

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
//        int a = plus(scan.nextInt());

//        List<Integer> list = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8);
//        list.forEach(o -> {
//            System.out.println(plus(o));
//        });

//        printStarsA(5,5);
        printStarsB(7);

    }
}
